package com.yonyou.pmclouds.billview.rmiimpl.buzi;

import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.PageObject;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.util.CommonFieldConst;
import com.yonyou.pmclouds.billview.entity.BillViewQueryVO;
import com.yonyou.pmclouds.billview.rmitf.IBillViewBuziService;
import com.yonyou.pmclouds.billview.util.BillViewUtil;
import com.yonyou.pmclouds.constructiondiary.entity.ConstructionDiaryVO;
import com.yonyou.pmclouds.constructiondiary.rmiitf.ConstructionDiaryQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ConstructionDirayBuziServiceImpl implements IBillViewBuziService {

    @Autowired
    private ConstructionDiaryQuery constructionDiaryQuery;

    @Override
    public String getBillType() {
        return BillTypeConst.CONSTRUCTION_DIARY_BILLTYPE;
    }

    @Override
    public PageObject<Object> queryBillList(BillViewQueryVO billViewQueryVO) throws BusinessException {

        PageObject<Object> constructionDiaryVOs = constructionDiaryQuery.queryByCondition(billViewQueryVO.getPkProject(),billViewQueryVO.getCreators(),
                billViewQueryVO.getStartTime(),billViewQueryVO.getEndTime(),billViewQueryVO.getBillStatus(),
                billViewQueryVO.getPageStart(),billViewQueryVO.getPageSize());
        BillViewUtil.setBillStatus(constructionDiaryVOs.getObjects());
        return constructionDiaryVOs;
    }

    @Override
    public SuperVO queryBillDetail(String pkBill) throws BusinessException {
        ConstructionDiaryVO constructionDiaryVO = constructionDiaryQuery.queryDetailByID(pkBill);
        BillViewUtil.setBillStatus(new ConstructionDiaryVO[]{constructionDiaryVO});
        BillViewUtil.setFormatDate(new Object[]{constructionDiaryVO},new String[]{CommonFieldConst.CREATIONTIME},new String[]{"strCreationtime"});

        return constructionDiaryVO;
    }
}
